package cn.yunhe.controller;

import cn.yunhe.entity.Topic;
import cn.yunhe.service.ItopicService;
import cn.yunhe.service.implService.TopicService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;

@WebServlet(name = "DeleteTopicByTidServlet",urlPatterns = "/DeleteTopicByTidServlet")
public class DeleteTopicByTidServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tidStr=request.getParameter("tid");
        int tid=0;
        if(tidStr!=null){
            tid=Integer.parseInt(tidStr);
        }
        ItopicService topicService=new TopicService();
        Topic topic=new Topic();
        topic.setTid(tid);
        boolean flag=topicService.deleteTopic(topic);
        response.sendRedirect("guestbook.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
